<?php
/*
*用户页面
*user.php
*by QINIAO
*/

//获得用户id
require_once('init.php');

$userid=isset($_GET["id"]) ? intval($_GET["id"]) :'';

$pageurl = '';

$page = isset($_GET['page']) ? abs(intval($_GET['page'])) : 1;
$pageurl .= './user.php?id='.$userid.'&page';

require_once('model/class.mlog.php');
require_once('model/class.user.php');
require_once('model/class.cates.php');
require_once('model/class.comment.php');
require_once('model/class.follow.php');
require_once('model/class.attachment.php');

$qiMlog = new qiMlog($DB);
$qiCate = new qiCate($DB);
$qiUser = new qiUser($DB);
$qiComment = new qiComment($DB);
$qiFollow = new qiFollow($DB);
$qiAttachment = new qiAttachment($DB);

$userDate = $qiUser->getOneUser($userid);

$mlogs = $qiMlog->getUserMlog($page,8,$userid);

$virtue = "uid";
$setvirtue = $userid;
$lognum = $qiMlog->getLogNum($virtue, $setvirtue);

foreach($mlogs as $key=>$val)
{
$val['cname'] = $qiCate->getCateName($val['cid']);
$val['truename'] = $qiUser->getUserName($val['uid']);
$val['comms'] = $qiComment->getComments($val['id']);
$val['photo'] = $qiAttachment->getMlogPic($val['aid']);
$mlogs[$key] = $val;
}

$page_url = pagination($lognum, 8, $page, $pageurl);

$followDate = $qiFollow->getUidFollow($userid);
$FidfollowDate = $qiFollow->getFidFollow($userid);

if(empty($cookienum))
{
$uid = '';
}


if($action == 'follow')
{
$fid = $_GET['id'];
if(empty($uid))
{
redirect('log.php?action=in', 2, '请登录后再进行操作！');
}
else
{
$qiFollow->ManageFollow($uid,$fid);
redirect('user.php?id='.$fid.'', 2, '操作成功，3秒钟返回！');
}
}

// 输出模板
$xingTemplate->display('user');
?>